Remove special casing of menu key events as it's no longer necessary;
authorRichard Hult <richard@imendio.com>
Mon, 12 May 2008 11:23:28 +0000 (11:23 +0000)
committerRichard Hult <rhult@src.gnome.org>
Mon, 12 May 2008 11:23:28 +0000 (11:23 +0000)
2008-05-12  Richard Hult  <richard@imendio.com>

* gdk/quartz/gdkevents-quartz.c:
* gdk/quartz/gdkquartz.h: Remove special casing of menu key events
as it's no longer necessary; instead the added quartz API to get
the nsevent from an event should be used. Also move the global
filter up so it's done before the check for window-less events.

svn path=/trunk/; revision=20100

ChangeLog
gdk/quartz/gdkevents-quartz.c

index 69628f62b22c0e7c0bedd48462f77e42cf20bcb9..612f7e1d978bfde964bc8503021e1d2bdca00465 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-05-12  Richard Hult  <richard@imendio.com>
+
+       * gdk/quartz/gdkevents-quartz.c:
+       * gdk/quartz/gdkquartz.h: Remove special casing of menu key events
+       as it's no longer necessary; instead the added quartz API to get
+       the nsevent from an event should be used. Also move the global
+       filter up so it's done before the check for window-less events.
+
 2008-05-12  Tor Lillqvist  <tml@novell.com>
 
        Bug 532558 - Cannot build dll when using separate builddir
index 397c6217cb058be9e883378986ba92d157906559..121d15085415b2f8d14d35760f0fb0d39290e223 100644 (file)
@@ -2,7 +2,7 @@
  *
  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
  * Copyright (C) 1998-2002 Tor Lillqvist
- * Copyright (C) 2005-2007 Imendio AB
+ * Copyright (C) 2005-2008 Imendio AB
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -105,17 +105,12 @@ which_window_is_this (GdkWindow *window)
   return buf;
 }
 
-/* A category that exposes the protected carbon event for an NSEvent. */
-@interface NSEvent (GdkQuartzNSEvent)
-- (void *)gdk_quartz_event_ref;
-@end 
-
-@implementation NSEvent (GdkQuartzNSEvent)
-- (void *)gdk_quartz_event_ref
+NSEvent *
+gdk_quartz_event_get_nsevent (GdkEvent *event)
 {
-  return _eventRef;
+  /* FIXME: If the event here is unallocated, we crash. */
+  return ((GdkEventPrivate *) event)->windowing_data;
 }
-@end
 
 void 
 _gdk_events_init (void)
@@ -1697,46 +1692,6 @@ gdk_event_translate (NSEvent *nsevent)
        */
     }
 
-  /* Special-case menu shortcut events. We create command events for
-   * those and forward to the corresponding menu.
-   */
-  if ((!_gdk_quartz_keyboard_grab_window ||
-       (_gdk_quartz_keyboard_grab_window && keyboard_grab_owner_events)) &&
-      [nsevent type] == NSKeyDown)
-    {
-      EventRef event_ref;
-      MenuRef menu_ref;
-      MenuItemIndex index;
-
-      event_ref = [nsevent gdk_quartz_event_ref];
-      if (IsMenuKeyEvent (NULL, event_ref,
-                          kMenuEventQueryOnly, 
-                          &menu_ref, &index))
-        {
-          MenuCommand menu_command;
-          HICommand hi_command;
-
-          if (GetMenuItemCommandID (menu_ref, index, &menu_command) != noErr)
-            return FALSE;
-   
-          hi_command.commandID = menu_command;
-          hi_command.menu.menuRef = menu_ref;
-          hi_command.menu.menuItemIndex = index;
-
-          CreateEvent (NULL, kEventClassCommand, kEventCommandProcess, 
-                       0, kEventAttributeUserEvent, &event_ref);
-          SetEventParameter (event_ref, kEventParamDirectObject, 
-                             typeHICommand, 
-                             sizeof (HICommand), &hi_command);
-
-          SendEventToEventTarget (event_ref, GetMenuEventTarget (menu_ref));
-
-          ReleaseEvent (event_ref);
-
-          return TRUE;
-        }
-    }
-
   /* Handle our generated "fake" crossing events. */
   if ([nsevent type] == NSApplicationDefined && 
       [nsevent subtype] == GDK_QUARTZ_EVENT_SUBTYPE_FAKE_CROSSING)
@@ -1766,6 +1721,19 @@ gdk_event_translate (NSEvent *nsevent)
 
   nswindow = [nsevent window];
 
+  /* Apply any global filters. */
+  if (_gdk_default_filters)
+    {
+      result = apply_filters (NULL, nsevent, _gdk_default_filters);
+
+      /* If result is GDK_FILTER_CONTINUE, we continue as if nothing
+       * happened. If it is GDK_FILTER_REMOVE,
+       * we return TRUE and won't send the message to Quartz.
+       */
+      if (result == GDK_FILTER_REMOVE)
+       return TRUE;
+    }
+
   /* Ignore events for no window or ones not created by GDK. */
   if (!nswindow || ![[nswindow contentView] isKindOfClass:[GdkQuartzView class]])
     return FALSE;
@@ -1780,19 +1748,6 @@ gdk_event_translate (NSEvent *nsevent)
       return FALSE;
     }
 
-  /* Apply any global filters. */
-  if (_gdk_default_filters)
-    {
-      result = apply_filters (NULL, nsevent, _gdk_default_filters);
-
-      /* If result is GDK_FILTER_CONTINUE, we continue as if nothing
-       * happened. If it is GDK_FILTER_REMOVE,
-       * we return TRUE and won't send the message to Quartz.
-       */
-      if (result == GDK_FILTER_REMOVE)
-       return TRUE;
-    }
-
   /* Take care of NSMouseEntered/Exited events and mouse movements
    * events and emit the right GDK crossing events.
    */